﻿//-----------------------------------------------------------------------
// <copyright file="UsageWebResponse.cs" company="Redmist">
//     Copyright (c) Damien T Smith. All rights reserved.
// </copyright>
// <author>Damien Smith</author>
//-----------------------------------------------------------------------

namespace Redmist.UsageMonitor.WebIO
{
    using System.IO;
    using System.Net;

    /// <summary>An implementation of Redmist.UsageMonitor.WebIO.IHttpWebResponse using System.Net.HttpWebResponse.</summary>
    public class UsageWebResponse : IHttpWebResponse
    {
        /// <summary>A System.Net.HttpWebResponse used for providing a response to HTTP requests.</summary>
        private HttpWebResponse httpWebResponse;

        /// <summary>Initializes a new instance of the UsageWebResponse class.</summary>
        /// <param name="httpWebResponse">A System.Net.HttpWebResponse used for providing a response to HTTP requests.</param>
        public UsageWebResponse(HttpWebResponse httpWebResponse)
        {
            this.httpWebResponse = httpWebResponse;
        }

        /// <summary>Gets the headers that are associated with this response from the server.</summary>
        public WebHeaderCollection Headers
        {
            get
            {
                return this.httpWebResponse.Headers;
            }
        }

        /// <summary>Closes the response stream.</summary>
        public void Close()
        {
            this.httpWebResponse.Close();
        }

        /// <summary>Gets the stream that is used to read the body of the response from the server.</summary>
        /// <returns>A System.IO.Stream containing the body of the response.</returns>
        public Stream GetResponseStream()
        {
            return this.httpWebResponse.GetResponseStream();
        }
    }
}
